package de.mmis.core.base.infrastructure;

/**
 * Additional information can be retrieved with the {@link #getType()}-result.
 * Note that it may return <b>null</b>.
 * 
 * @author Martin Nyolt
 * 
 */
public class InfrastructureException extends Exception {

	private static final long serialVersionUID = 8226301680755892891L;

	/**
	 * indicate the type of error
	 * 
	 * @author Martin Nyolt
	 */
	public static enum Type {
		/** the server is not running or could not be started */
		NOT_RUNNING,

		/**
		 * the {@link PublishedDeviceDescription} was a pattern, but a
		 * non-pattern description was expected
		 */
		IS_PATTERN,

		/**
		 * e.g. if a message could not be send
		 */
		NETWORK_ERROR
	}

	private Type type;

	public InfrastructureException() {
		super();
	}

	public InfrastructureException(String message) {
		super(message);
	}

	public InfrastructureException(Throwable cause) {
		super(cause);
	}

	public InfrastructureException(String message, Throwable cause) {
		super(message, cause);
	}

	/**
	 * @return the type of the exception. May return <b>null</b>.
	 */
	public Type getType() {
		return this.type;
	}

	/**
	 * sets the type
	 * 
	 * @return the instance
	 */
	public InfrastructureException setType(Type type) {
		this.type = type;
		return this;
	}

}
